package com.ruoyi.web.controller.system;

import java.util.List;
import javax.servlet.http.HttpServletResponse;
import org.springframework.security.access.prepost.PreAuthorize;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.web.bind.annotation.GetMapping;
import org.springframework.web.bind.annotation.PostMapping;
import org.springframework.web.bind.annotation.PutMapping;
import org.springframework.web.bind.annotation.DeleteMapping;
import org.springframework.web.bind.annotation.PathVariable;
import org.springframework.web.bind.annotation.RequestBody;
import org.springframework.web.bind.annotation.RequestMapping;
import org.springframework.web.bind.annotation.RestController;
import com.ruoyi.common.annotation.Log;
import com.ruoyi.common.core.controller.BaseController;
import com.ruoyi.common.core.domain.AjaxResult;
import com.ruoyi.common.enums.BusinessType;
import com.ruoyi.system.domain.TbMaliceMail;
import com.ruoyi.system.service.ITbMaliceMailService;
import com.ruoyi.common.utils.poi.ExcelUtil;
import com.ruoyi.common.core.page.TableDataInfo;

/**
 * 恶意邮件指标填报Controller
 * 
 * @author wyl
 * @date 2025-02-17
 */
@RestController
@RequestMapping("/system/mail")
public class TbMaliceMailController extends BaseController
{
    @Autowired
    private ITbMaliceMailService tbMaliceMailService;

    /**
     * 查询恶意邮件指标填报列表
     */
    @PreAuthorize("@ss.hasPermi('system:mail:list')")
    @GetMapping("/list")
    public TableDataInfo list(TbMaliceMail tbMaliceMail)
    {
        startPage();
        List<TbMaliceMail> list = tbMaliceMailService.selectTbMaliceMailList(tbMaliceMail);
        return getDataTable(list);
    }

    /**
     * 导出恶意邮件指标填报列表
     */
    @PreAuthorize("@ss.hasPermi('system:mail:export')")
    @Log(title = "恶意邮件指标填报", businessType = BusinessType.EXPORT)
    @PostMapping("/export")
    public void export(HttpServletResponse response, TbMaliceMail tbMaliceMail)
    {
        List<TbMaliceMail> list = tbMaliceMailService.selectTbMaliceMailList(tbMaliceMail);
        ExcelUtil<TbMaliceMail> util = new ExcelUtil<TbMaliceMail>(TbMaliceMail.class);
        util.exportExcel(response, list, "恶意邮件指标填报数据");
    }

    /**
     * 获取恶意邮件指标填报详细信息
     */
    @PreAuthorize("@ss.hasPermi('system:mail:query')")
    @GetMapping(value = "/{emailId}")
    public AjaxResult getInfo(@PathVariable("emailId") Long emailId)
    {
        return success(tbMaliceMailService.selectTbMaliceMailByEmailId(emailId));
    }

    /**
     * 新增恶意邮件指标填报
     */
    @PreAuthorize("@ss.hasPermi('system:mail:add')")
    @Log(title = "恶意邮件指标填报", businessType = BusinessType.INSERT)
    @PostMapping
    public AjaxResult add(@RequestBody TbMaliceMail tbMaliceMail)
    {
        return toAjax(tbMaliceMailService.insertTbMaliceMail(tbMaliceMail));
    }

    /**
     * 修改恶意邮件指标填报
     */
    @PreAuthorize("@ss.hasPermi('system:mail:edit')")
    @Log(title = "恶意邮件指标填报", businessType = BusinessType.UPDATE)
    @PutMapping
    public AjaxResult edit(@RequestBody TbMaliceMail tbMaliceMail)
    {
        return toAjax(tbMaliceMailService.updateTbMaliceMail(tbMaliceMail));
    }

    /**
     * 删除恶意邮件指标填报
     */
    @PreAuthorize("@ss.hasPermi('system:mail:remove')")
    @Log(title = "恶意邮件指标填报", businessType = BusinessType.DELETE)
	@DeleteMapping("/{emailIds}")
    public AjaxResult remove(@PathVariable Long[] emailIds)
    {
        return toAjax(tbMaliceMailService.deleteTbMaliceMailByEmailIds(emailIds));
    }
}
